using System.Threading.Tasks;
using UniversalAdminSystem.Domian.Core.ValueObjects;

namespace UniversalAdminSystem.Domian.UserConversations.Aggregates;

public class Conversations
{
    public ConversationId Id { get; private set; } = null!;

    public UserId UserId { get; private set; } = null!;

    public string? Title { get; private set; }

    public DateTime CreateDate { get; private set; }

    public DateTime UpdateDate { get; private set; }

    protected Conversations() { }

    private Conversations(ConversationId id, UserId userid, string? title, DateTime createDate, DateTime updateDate)
    {
        Id = id;
        UserId = userid;
        Title = title;
        CreateDate = createDate;
        UpdateDate = updateDate;
    }

    public static Conversations Create(Guid userid, string? title)
    {
        if (userid == Guid.Empty) throw new ArgumentException("用户id不能为空");
        return new Conversations(
            ConversationId.Create(Guid.NewGuid()),
            UserId.Create(userid),
            title,
            DateTime.UtcNow,
            DateTime.UtcNow
        );
    }

    public void UpdateUpdateDate(DateTime time)
    {
        UpdateDate = time;
    }
}